const lengthOfLIS = (nums) => {
  const dp = [];
  const n = nums.length;
  if (!n) return 0;
  dp[0] = 1;
  for (let i = 1; i < n; i++) {
    let max = 1;
    const num = nums[i];
    for (let j = 0; j < i; j++) {
      const prevNum = nums[j];
      if (prevNum < num) {
        max = Math.max(max, dp[j] + 1);
      }
    }
    dp[i] = max;
  }
  return Math.max(...dp);
};
